/**
 * Copyright © 2018 陈锦韬  All rights reserved.
 * 
 * @Package: com.rx.init 
 * @author: Administrator   
 * @date: 2018年4月14日 下午2:13:22
 */
package com.rx.init;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import com.rx.core.dbo.DbTableOperate;
import com.rx.core.enm.RX_ERROR;

/**
 * @className: SystemInit 
 * @author: Administrator
 * @Description: TODO
 * @date: 2018年4月14日 下午2:13:22
 */
@Component

public class SystemInit  implements ApplicationListener<ApplicationReadyEvent > {

	public static final Logger logger = LoggerFactory.getLogger(DbTableOperate.class);
	public static boolean first = true;
	
	@Autowired
	private DbTableOperate dbTableOperate;

	@Override
	public void onApplicationEvent(ApplicationReadyEvent arg0) {
		try {
			if(first){
				first = false;
				dbTableOperate.InitDatabaseOnes();
		
			}

		} catch (Exception e) {
			logger.error(RX_ERROR.SQL_C_ERROR.message()+"：初始化数据库失败");
		}
		
	}
}
